package com.kky.pp.activity.user
import android.os.Handler
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import com.bumptech.glide.Glide
import com.custom.base.mvp.MVPBaseActivity
import com.gyf.immersionbar.ImmersionBar
import com.kky.pp.R
import com.kky.pp.databinding.ActivityUserProfileBinding
import com.kky.pp.view.ProfileInfoTurnOnsView
import com.kky.pp.util.DensityUtil
import com.kky.pp.view.TagCloudView
import com.kky.pp.view.delay.DelayClickImageView
import com.youth.banner.Banner


/**
 * 设置app
 */
class UserProfileInfoActivity : MVPBaseActivity<UserProfileInfoContract.View, UserProfileInfoPresenter,ActivityUserProfileBinding>(ActivityUserProfileBinding::inflate),
    UserProfileInfoContract.View {

    companion object{
        val ACTIVITY_RESULT_CODE = 1001
    }

    override fun setFullScreen(): Boolean {
        return true
    }
    override fun bindLayout(): Int {
        return R.layout.activity_user_profile
    }


    override fun initView() {
        val params = viewBinding.bannerPersonalInformation.layoutParams as FrameLayout.LayoutParams
        params.width = DensityUtil.getScreenWidth(this)
        params.height = (DensityUtil.getScreenWidth(this) * 1.1173).toInt()
        val imagUrl = if (intent.getStringExtra("url").isNullOrEmpty()){
            intent.extras?.get("url").toString()
        }else{
            intent.getStringExtra("url")
        }
        Glide.with(this).load(imagUrl).into(viewBinding.imgViewPersonalInformationSeatImg)
        Handler().postDelayed({
            viewBinding.imgViewPersonalInformationSeatImg.isVisible = false
        },1000L)
        viewBinding.imgViewPersonalInformationBack.setOnClickListener {
            onBackPressed()
        }
    }

    override fun onBackPressed() {
        viewBinding.imgViewPersonalInformationSeatImg.isVisible = true
        intent.putExtra("currentItem",viewBinding.bannerPersonalInformation.currentItem)
        setResult(ACTIVITY_RESULT_CODE,intent)
        super.onBackPressed()
//        finish()
    }

    override fun onResume() {
        super.onResume()
        ImmersionBar.with(this)
            .barAlpha(0f).statusBarDarkFont(false)
            .init()
    }

    override val bannerPersonalInformationList: Banner<*, *>
        get() = viewBinding.bannerPersonalInformation
    override val imgViewPersonalInformationBacks: ImageView
        get() = viewBinding.imgViewPersonalInformationBack
    override val imgViewPersonalInformationMenus: ImageView
        get() = viewBinding.imgViewPersonalInformationMenu
    override val txtPersonalInformationStatus: TextView
        get() = viewBinding.txtPersonalInformationStatus
    override val txtPersonalInformationPositioning: TextView
        get() = viewBinding.txtPersonalInformationPositioning
    override val txtPersonalInformationNickName: TextView
        get() = viewBinding.txtPersonalInformationNickName
    override val txtPersonalInformationAboutMeTitle: TextView
        get() = viewBinding.txtPersonalInformationAboutMeTitle
    override val txtPersonalInformationHobbyTitle: TextView
        get() = viewBinding.txtPersonalInformationHobbyTitle
    override val txtPersonalInformationIntroduce: TextView
        get() = viewBinding.txtPersonalInformationIntroduce
    override val tagPersonalInformation: TagCloudView
        get() = viewBinding.tagPersonalInformation
    override val imgViewPersonalInformationUnLike: DelayClickImageView
        get() = viewBinding.imgViewPersonalInformationUnLike
    override val imgViewPersonalInformationLike: DelayClickImageView
        get() = viewBinding.imgViewPersonalInformationLike
    override val imgViewPersonalInformationChat: DelayClickImageView
        get() = viewBinding.imgViewPersonalInformationChat
    override val conPersonalInformationBottomContainer: ConstraintLayout
        get() = viewBinding.conPersonalInformationBottomContainer
    override val turnOnsViewPersonalInformation: ProfileInfoTurnOnsView
        get() = viewBinding.turnOnsViewPersonalInformation
    override val turnOnsViewPersonalInformationTitle: TextView
        get() = viewBinding.turnOnsViewPersonalInformationTitle
    override val framePersonalInformationTopTitle: FrameLayout
        get() = viewBinding.framePersonalInformationTopTitle
    override val txtPersonalInformationPurpose: TextView
        get() = viewBinding.txtPersonalInformationPurpose
    override val txtPersonalInformationConstellation: TextView
        get() = viewBinding.txtPersonalInformationConstellation
    override val txtPersonalInformationHigh: TextView
        get() = viewBinding.txtPersonalInformationHigh


}